Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UX improvement in relayer #541

Merged
merged 13 commits into from
Jan 21, 2021
Merged

UX improvement in relayer #541

merged 13 commits into from
Jan 21, 2021

Conversation

adizere
Copy link
Member

@adizere adizere commented Jan 19, 2021

Closes: #540
Closes: #536

Summary of changes:

  • For all tx raw commands, removed the unwrap call after ChainRuntime::spawn and added error-handling code. This results in JSON error output in case the light client is not initialized, instead of panics:

{"status":"error","result":["chain runtime/handle error: Light client supervisor error for chain id ibc-1: missing light client primary peer config"]}

  • For queries, the error returned if the target chain is not running is now more explicit, including the endpoint IP addr:

{"status":"error","result":["query error: RPC error to endpoint tcp://localhost:26657: error trying to connect: tcp connect error: Connection refused (os error 61) (code: 0)"]}

  • the start command now runs the v0 relayer; deleted the v0 command
  • introduced a log_level parameter in the relayer configuration file, so now we can enable error-only logging if we wish.
    • a final output from the program will always exist in JSON format.
    • introducing the prevaleent use of tracing info!, debug! etc macros, as replacements for abscissa status_... macros; both tracing and abscissa macros will adhere to the log_level parameter.

For contributor use:

  • Updated the Unreleased section of CHANGELOG.md with the issue.
  • If applicable: Unit tests written, added test to CI.
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments.
  • Re-reviewed Files changed in the Github PR explorer.

@codecov-io
Copy link

codecov-io commented Jan 20, 2021

Codecov Report

Merging #541 (d638cc3) into master (b1b37f5) will increase coverage by 26.7%.
The diff coverage is 69.4%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #541      +/-   ##
=========================================
+ Coverage    13.6%   40.4%   +26.7%     
=========================================
  Files          69     134      +65     
  Lines        3752    8487    +4735     
  Branches     1374       0    -1374     
=========================================
+ Hits          513    3434    +2921     
- Misses       2618    5053    +2435     
+ Partials      621       0     -621     
Impacted Files Coverage Δ
...application/ics20_fungible_token_transfer/error.rs 0.0% <0.0%> (ø)
...pplication/ics20_fungible_token_transfer/events.rs 0.0% <ø> (ø)
...ion/ics20_fungible_token_transfer/msgs/transfer.rs 0.0% <0.0%> (ø)
modules/src/events.rs 0.0% <0.0%> (ø)
modules/src/ics02_client/error.rs 100.0% <ø> (ø)
modules/src/ics02_client/events.rs 0.0% <0.0%> (ø)
modules/src/ics02_client/raw.rs 0.0% <0.0%> (ø)
modules/src/ics03_connection/error.rs 100.0% <ø> (+66.6%) ⬆️
modules/src/ics03_connection/events.rs 0.0% <0.0%> (ø)
modules/src/ics04_channel/error.rs 100.0% <ø> (+75.0%) ⬆️
... and 229 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a79d35...fc67361. Read the comment docs.

@adizere adizere changed the title UX improvement in relayer txs UX improvement in relayer Jan 20, 2021
@adizere adizere marked this pull request as ready for review January 20, 2021 15:18
Copy link
Collaborator

@ancazamfir ancazamfir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great improvements! Could you please also update the relayer operating instructions and the .toml example files to show how to control the logging.

@adizere
Copy link
Member Author

adizere commented Jan 20, 2021

Great improvements! Could you please also update the relayer operating instructions and the .toml example files to show how to control the logging.

Good point, that's something I overlooked!
d638cc3

Copy link
Member

@romac romac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Left a couple suggestions but feel free to ignore if you feel it doesn't improve things much or can just come at a later point.

Comment on lines 60 to 63
Ok(r) => Output::with_success().with_result(json!(r)).exit(),
Err(e) => Output::with_error()
.with_result(json!(format!("{}", e)))
.exit(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could introduce a couple helpers to streamline such code a bit, eg.

Suggested change
Ok(r) => Output::with_success().with_result(json!(r)).exit(),
Err(e) => Output::with_error()
.with_result(json!(format!("{}", e)))
.exit(),
Ok(r) => Output::success(json!(r)).exit(),
Err(e) => Output::error(json!(format!("{}", e))).exit(),

Copy link
Member

@romac romac Jan 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, what do you think about changing the type of success/error/with_result to

pub fn with_result(mut self, res: impl Serialize) -> Self {
        self.result.push(serde_json::to_value(res).unwrap()); // same unwrap as in `json!` macro
        self
    }

which would result into

Suggested change
Ok(r) => Output::with_success().with_result(json!(r)).exit(),
Err(e) => Output::with_error()
.with_result(json!(format!("{}", e)))
.exit(),
Ok(r) => Output::success(r).exit(),
Err(e) => Output::error(format!("{}", e)).exit(),

Having to call unwrap on the result of serde_json::to_value is unfortunate, but that's actually what the json! macro does under the hood so perhaps it's okay?

Also note that this would still allow passing a custom JSON object with the json! macro:

Output::success(json!({ "hello": "world" })).exit()

Reason is that json! returns a Value whose Serialize instance produces the same Value when given to to_value.

Copy link
Collaborator

@ancazamfir ancazamfir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I agree with Romain's comments, it would be nice to have that in this PR if it's a quick change. I will leave this up to you.

@adizere adizere merged commit 80d222b into master Jan 21, 2021
@adizere adizere deleted the adi/523_ux branch January 21, 2021 10:34
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* Avoid unwraps in client txs. Better LightClient errors.

* Avoided unwrap calls in tx raw commands

* Tagged relayer RPC error with the culprit IP address.

* Replaced start with v0

* Introduced logging levels. WIP: remove status_ calls

* Updated the sample config file

* Adapted keys commands to JSON output

* Transition to tracing macros & JSON outputs

* Changelog

* Added operation instructions.

* Simplified Output usage; h/t Romain's suggestions.

* Better err message for client consensus query
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UX improvements for relayer txs Cleanup output of relayer commands
4 participants